package org.apache.flink.runtime.resourceconsumer;

import java.io.Serializable;
import java.util.UUID;

import org.apache.flink.runtime.providermanager.UnresolvedProviderManagerLocation;
import org.apache.flink.util.Preconditions;

/** DTO for ResourceProvider registration information. */
public class ResourceProviderRegistrationInformation implements Serializable {
    private static final long serialVersionUID = 1767026305134276540L;

    private final String taskManagerRpcAddress;
    private final UnresolvedProviderManagerLocation unresolvedTaskManagerLocation;
    private final UUID taskManagerSession;

    private ResourceProviderRegistrationInformation(
            String taskManagerRpcAddress,
            UnresolvedProviderManagerLocation unresolvedTaskManagerLocation,
            UUID taskManagerSession) {
        this.taskManagerRpcAddress = Preconditions.checkNotNull(taskManagerRpcAddress);
        this.unresolvedTaskManagerLocation =
                Preconditions.checkNotNull(unresolvedTaskManagerLocation);
        this.taskManagerSession = Preconditions.checkNotNull(taskManagerSession);
    }

    public String getTaskManagerRpcAddress() {
        return taskManagerRpcAddress;
    }

    public UnresolvedProviderManagerLocation getUnresolvedTaskManagerLocation() {
        return unresolvedTaskManagerLocation;
    }

    public UUID getTaskManagerSession() {
        return taskManagerSession;
    }

    public static ResourceProviderRegistrationInformation create(
            String taskManagerRpcAddress,
            UnresolvedProviderManagerLocation unresolvedTaskManagerLocation,
            UUID taskManagerSession) {
        return new ResourceProviderRegistrationInformation(
                taskManagerRpcAddress, unresolvedTaskManagerLocation, taskManagerSession);
    }
}
